In [19]:
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
In [27]:
sns.set_style('whitegrid')
In [28]:
titanic = sns.load_dataset('titanic')
In [40]:
titanic.head()
Out[40]:
Recreate the plots below using the titanic dataframe. There are very few hints since most of the plots can be done with just one or two lines of code and a hint would basically give away the solution. Keep careful attention to the x and y labels for hints.
Note! In order to not lose the plot image, make sure you don't code in the cell that is directly above the plot, there is an extra cell above that one which won't overwrite that plot!
In [42]:
# CODE HERE
# REPLICATE EXERCISE PLOT IMAGE BELOW
# BE CAREFUL NOT TO OVERWRITE CELL BELOW
# THAT WOULD REMOVE THE EXERCISE PLOT IMAGE!
In [41]:
sns.jointplot(x='fare',y='age',data=titanic)
Out[41]:
In [43]:
# CODE HERE
# REPLICATE EXERCISE PLOT IMAGE BELOW
# BE CAREFUL NOT TO OVERWRITE CELL BELOW
# THAT WOULD REMOVE THE EXERCISE PLOT IMAGE!
In [44]:
sns.distplot(titanic['fare'],bins=30,kde=False,color='red')
Out[44]:
In [ ]:
# CODE HERE
# REPLICATE EXERCISE PLOT IMAGE BELOW
# BE CAREFUL NOT TO OVERWRITE CELL BELOW
# THAT WOULD REMOVE THE EXERCISE PLOT IMAGE!
In [45]:
sns.boxplot(x='class',y='age',data=titanic,palette='rainbow')
Out[45]:
In [ ]:
# CODE HERE
# REPLICATE EXERCISE PLOT IMAGE BELOW
# BE CAREFUL NOT TO OVERWRITE CELL BELOW
# THAT WOULD REMOVE THE EXERCISE PLOT IMAGE!
In [46]:
sns.swarmplot(x='class',y='age',data=titanic,palette='Set2')
Out[46]:
In [ ]:
# CODE HERE
# REPLICATE EXERCISE PLOT IMAGE BELOW
# BE CAREFUL NOT TO OVERWRITE CELL BELOW
# THAT WOULD REMOVE THE EXERCISE PLOT IMAGE!
In [47]:
sns.countplot(x='sex',data=titanic)
Out[47]:
In [ ]:
# CODE HERE
# REPLICATE EXERCISE PLOT IMAGE BELOW
# BE CAREFUL NOT TO OVERWRITE CELL BELOW
# THAT WOULD REMOVE THE EXERCISE PLOT IMAGE!
In [48]:
sns.heatmap(titanic.corr(),cmap='coolwarm')
plt.title('titanic.corr()')
Out[48]:
In [ ]:
# CODE HERE
# REPLICATE EXERCISE PLOT IMAGE BELOW
# BE CAREFUL NOT TO OVERWRITE CELL BELOW
# THAT WOULD REMOVE THE EXERCISE PLOT IMAGE!
In [49]:
g = sns.FacetGrid(data=titanic,col='sex')
g.map(plt.hist,'age')
Out[49]: